package interview;
/*请自己实现两个整数变量的交换
 * 
 * */
public class Interview03 {
	public static void main(String[] args) {
		
		int a=10;
		int b=20;
		one(a,b);
		two(a,b);
		three(a,b);
		fore(a,b);
		five(a,b);
	}
	private static void one(int a,int b){
		int c=0;
		c=a;
		a=b;
		b=c;
		System.out.println("a="+a+";b="+b);
		

	}
	private static void two(int a,int b){
		//面试用
		a=a^b;
		b=a^b;//a^b^b=a
		a=a^b;//a^b^a=b
				
		System.out.println("a="+a+";b="+b);

	}
	private static void five(int a,int b){
		//面试用
		a^=b;
		b^=a;
		a^=b;
				
		System.out.println("a="+a+";b="+b);

	}
	private static void three(int a,int b){
		a=a+b;//a=30
		b=a-b;//b=10
		a=a-b;//a=20
		System.out.println("a="+a+";b="+b);
	}
	private static void fore(int a,int b){
		b=(a-b)+(a=b);
		System.out.println("a="+a+";b="+b);
	}

}
